/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.AddAccountAliasRequest;
/*    */ import com.zimbra.soap.admin.message.AddAccountAliasResponse;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AddAccountAlias
/*    */   extends AdminDocumentHandler
/*    */ {
/* 45 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/*    */   
/* 47 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 54 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 62 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 68 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 69 */     Provisioning prov = Provisioning.getInstance();
/* 70 */     AddAccountAliasRequest req = (AddAccountAliasRequest)JaxbUtil.elementToJaxb(request);
/*    */     
/* 72 */     String id = req.getId();
/* 73 */     String alias = req.getAlias();
/*    */     
/* 75 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/*    */     
/* 77 */     defendAgainstAccountOrCalendarResourceHarvesting(account, Key.AccountBy.id, id, zsc, Rights.Admin.R_addAccountAlias, Rights.Admin.R_addCalendarResourceAlias);
/*    */     
/*    */ 
/*    */ 
/* 81 */     checkDomainRightByEmail(zsc, alias, Rights.Admin.R_createAlias);
/*    */     
/* 83 */     prov.addAlias(account, alias);
/* 84 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddAccountAlias", "name", account.getName(), "alias", alias }));
/*    */     
/*    */ 
/* 87 */     return zsc.jaxbToElement(new AddAccountAliasResponse());
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 92 */     relatedRights.add(Rights.Admin.R_addCalendarResourceAlias);
/* 93 */     relatedRights.add(Rights.Admin.R_addAccountAlias);
/* 94 */     relatedRights.add(Rights.Admin.R_createAlias);
/*    */     
/* 96 */     notes.add("Need " + Rights.Admin.R_createAlias.getName() + " right on the domain in which the alias is to be created.");
/* 97 */     notes.add("Need " + Rights.Admin.R_addAccountAlias.getName() + " right if adding alias for an account.");
/* 98 */     notes.add("Need " + Rights.Admin.R_addCalendarResourceAlias.getName() + " right if adding alias for a calendar resource.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/AddAccountAlias.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */